package main.service;

import java.util.List;

import main.dao.GirlRepository;
import main.entity.Girl;
import main.util.PageableTool;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class GirlService {

	@Autowired
	private GirlRepository girlRepository;
	
	
	public Page<Girl> getGirlByBoyId(String name,Pageable pageable) {
		return girlRepository.findByBoyFriend_Name(name,pageable);
	}
	
	public List<Girl> getGirl(String address) {
		//return girlRepository.findByBoyFriend(boy);
		return girlRepository.findByBoyFriend_Address(address);
	}
	
	public Page<Girl> getGirlByNameAndId(String name,Integer id,Integer page) {
		
		Pageable pageable = PageableTool.basicPage(page,Girl.AGE);
		
		return girlRepository.findByParams(name, id,pageable);
	}
	
	public Page<Girl> getGirlByName(String name,Pageable pageable) {
		return girlRepository.findPageByParam(name, pageable);
	}
}
